// 快速排序
let arr = [0,25,2,8,1,6,9,5]

function quickSort(arr) {

    if(arr.length <= 1) return arr
    const len = Math.floor(arr.length/2)
    // 基准数,且删除这个基准数
    const model = arr.splice(len, 1)[0] 
    let left = [], right = []

    for(let i = 0; i < arr.length; i++) {
        if(model >= arr[i]) {
            left.push(arr[i])
        }
        else {
            right.push(arr[i])
        }
    }
    return quickSort(left).concat([model], quickSort(right))
}
console.log(quickSort(arr));